home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / pmake / lst / lstInt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-19  |  2.4 KB  |  86 lines

  1. /*-
  2.  * lstInt.h --
  3.  *    Internals for the list library
  4.  *
  5.  * Copyright (c) 1988 by University of California Regents
  6.  *
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appears in all copies.  Neither the University of California nor
  11.  * Adam de Boor makes any representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  * $Id: lstInt.h,v 1.12 92/05/18 17:47:29 kupfer Exp $ SPRITE (Berkeley)
  16.  */
  17. #ifndef _LSTINT_H_
  18. #define _LSTINT_H_
  19.  
  20. #include      <sprite.h>
  21. #include      "lst.h"
  22.  
  23. typedef struct ListNode {
  24.     struct ListNode    *prevPtr;   /* previous element in list */
  25.     struct ListNode    *nextPtr;   /* next in list */
  26.     short            useCount:8, /* Count of functions using the node.
  27.                      * node may not be deleted until count
  28.                      * goes to 0 */
  29.                      flags:8;    /* Node status flags */
  30.     ClientData    datum;        /* datum associated with this element */
  31. } *ListNode;
  32. /*
  33.  * Flags required for synchronization
  34.  */
  35. #define LN_DELETED      0x0001      /* List node should be removed when done */
  36.  
  37. #define NilListNode    ((ListNode)NIL)
  38.  
  39. typedef enum {
  40.     Head, Middle, Tail, Unknown
  41. } Where;
  42.  
  43. typedef struct    {
  44.     ListNode      firstPtr; /* first node in list */
  45.     ListNode      lastPtr;  /* last node in list */
  46.     Boolean          isCirc;      /* true if the list should be considered
  47.                    * circular */
  48. /*
  49.  * fields for sequential access
  50.  */
  51.     Where          atEnd;      /* Where in the list the last access was */
  52.     Boolean          isOpen;      /* true if list has been Lst_Open'ed */
  53.     ListNode      curPtr;      /* current node, if open. NilListNode if
  54.                    * *just* opened */
  55.     ListNode      prevPtr;  /* Previous node, if open. Used by
  56.                    * Lst_Remove */
  57. } *List;
  58.  
  59. #define NilList          ((List)NIL)
  60.  
  61. /*
  62.  * PAlloc (var, ptype) --
  63.  *    Allocate a pointer-typedef structure 'ptype' into the variable 'var'
  64.  */
  65. #define    PAlloc(var,ptype)    var = (ptype) Malloc (sizeof (*var))
  66.  
  67. /*
  68.  * LstValid (l) --
  69.  *    Return TRUE if the list l is valid
  70.  */
  71. #define LstValid(l)    (((Lst)l == NILLST) ? FALSE : TRUE)
  72.  
  73. /*
  74.  * LstNodeValid (ln, l) --
  75.  *    Return TRUE if the LstNode ln is valid with respect to l
  76.  */
  77. #define LstNodeValid(ln, l)    ((((LstNode)ln) == NILLNODE) ? FALSE : TRUE)
  78.  
  79. /*
  80.  * LstIsEmpty (l) --
  81.  *    TRUE if the list l is empty.
  82.  */
  83. #define LstIsEmpty(l)    (((List)l)->firstPtr == NilListNode)
  84.  
  85. #endif _LSTINT_H_
  86.